#include <asm.h>
#include <regdef.h>
#include <new_inst_test.h>

LEAF(my22_bal_test)
    .set noreorder
    addiu s0,s0,1
    li    s2,0
###test inst
    li t0,0x800d6000
    sw ra,0(t0)
    TEST_BAL(0x12334,0x12433,bal_pc_0)
    TEST_BAL(0x1225f,0x1b0c,bal_pc_1)
    TEST_BAL(0x10ec2,0xfffd9138,bal_pc_2)
    TEST_BAL(0xf74d3,0xfffc6555,bal_pc_3)
    TEST_BAL(0x13c56,0x12349,bal_pc_4)
    TEST_BAL(0x12334,0x12433,bal_pc_5)
    TEST_BAL(0x05259,0x12433,bal_pc_6)
    TEST_BAL(0x540c61,0x12433,bal_pc_7)
    TEST_BAL(0x12334,0x9bd33,bal_pc_8)
###detect exception
    bne s2,zero,inst_error
    nop
###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
test:
    beq s0,s3,inst_error
    nop
    addiu s3,s3,1
    j test
    nop
inst_error:
    sll t1, s0, 24
    or t0, t1, s3
    sw t0, 0(s1)
    li t7,0x800d6000
    lw ra,0(t7)
    jr ra
    nop
END(my22_bal_test)
